#include "calc_neighborhoods.h"

int main(int argc, char** argv) {
  struct store * atomStore, * neighStore;
  struct mTree * atomTree,  * neighTree;

  if(argc != 6) {
    printf("This program takes exactly five arguments; the four letter pdb code, the neighborhood store, the neighborhood store fat, the neighborhood index, and its fat.  (Argument count was %d)  Size of aa_bond_nei\
ghborhood is %d\n", argc - 1, sizeof(struct aa_bond_neighborhood));
    return 1;
  }

  atomStore  = store_open_cached("neigh_store.atoms", "neigh_store.atoms.fat", sizeof(struct atom), 100, 120000);
  atomTree   = mTree_open_cached(atomStore, "neigh_store.mTree", "neigh_store.mTree.fat", 80000, (double(*)(const void*,const void*))&atom_distance);
  neighStore = store_open_cached(argv[2],argv[3], sizeof(struct aa_bond_neighborhood), 100, 5000000);
  neighTree  = mTree_open_cached(neighStore, argv[4], argv[5], 200000, (double(*)(const void*,const void*))&aa_bond_neighborhood_distance);

  calc_neighborhoods(argv[1], 30 * 1000, atomStore, atomTree, neighStore, neighTree);
  printf("Neighborhood tree !\n");
  mTree_printStats(neighTree);
  
  mTree_close(neighTree);
  store_close(neighStore);

  printf("Atom tree\n");
  mTree_printStats(atomTree);

  mTree_close(atomTree);
  store_close(atomStore);

  return 0;

}



/*#include "../bulk_storage/bulk_storage.h"
#include "../m_tree/mTree.h"
#include "aa_bond_neighborhood.h"

int main(int argc, char ** argv) {
  struct store * neighborhoodStore;


  struct mTree * neighborhoodTree;

  struct aa_bond_neighborhood * n;

  off_t idx = 0;

  if(argc != 3) {
    printf("This program requires two arguments, the mTree output file, and the mTree's fat output file\n");
  }

  neighborhoodStore = store_open_cached("neigh_store", "neigh_store.fat", sizeof(struct aa_bond_neighborhood), 100, 1000);
  neighborhoodTree = mTree_open_cached(neighborhoodStore, 
				       //				       "pdb_neighborhood.mTree", "pdb_neighborhood.mTree.fat",  
				       argv[1], argv[2],
				       10000, 
				       (double(*)(void*,void*))&aa_bond_neighborhood_distance);

  n = store_read(neighborhoodStore,idx);

  while(n->center.serial) {

    mTree_insert(neighborhoodTree, idx);

    store_release(neighborhoodStore, idx);
    idx++;
    n = store_read(neighborhoodStore, idx);
  }
  store_release(neighborhoodStore, idx);
  mTree_close(neighborhoodTree);
  store_close(neighborhoodStore);
  return 0;
}
*/
